package org.spring.config.server.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.spring.config.server.model.Properties;
import org.springframework.transaction.annotation.Transactional;


@Mapper
@Transactional
public interface ProDao {

	@Select("select * from properties t where t.id = #{id}")
	Properties getById(Long id);

	@Delete("delete from properties where id = #{id}")
	int delete(Long id);

	int update(Properties properties);

	@Options(useGeneratedKeys = true, keyProperty = "id")
	@Insert("insert into properties( k, val, application, profile,lable) values(#{k}, #{val}, #{application}, #{profile},#{lable})")
	int save(Properties properties);

	int count(@Param("params") Map<String, Object> params);

	List<Properties> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset,
			@Param("limit") Integer limit);

	@Select("select * from properties t where t.type = #{type} and k = #{k}")
	Properties getByTypeAndK(@Param("type") String type, @Param("k") String k);

	@Select("select * from properties t where t.type = #{type}")
	List<Properties> listByType(String type);
}
